package com.ruoyi.web.controller.system;

/*
* 商铺与消费大屏
* Mr.zzs
* */


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.system.domain.StoreAndConsumeScreenVo;
import com.ruoyi.system.service.StoreAndConsumeScreenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import sun.applet.resources.MsgAppletViewer;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/screen/storeAndConsume")
public class StoreAndConsumeScreenController {

    @Autowired
    private StoreAndConsumeScreenService storeAndConsumeScreenService;


    @PostMapping("getOneFrame")
    @ResponseBody
    public StoreAndConsumeScreenVo getOneFrame(){
        Integer currentMonthAdd = storeAndConsumeScreenService.selectCurrentMonthAdd();
        Integer storeTotal = storeAndConsumeScreenService.selectStoreTotal();
        List<HashMap<String, Integer>> hashMaps = storeAndConsumeScreenService.selectPercent();
        StoreAndConsumeScreenVo storeAndConsumeScreenVo = new StoreAndConsumeScreenVo();
        storeAndConsumeScreenVo.setCurrentMonthAdd(currentMonthAdd);
        storeAndConsumeScreenVo.setStoreTotal(storeTotal);
     //   storeAndConsumeScreenVo.setStorePercent(hashMaps);
        storeAndConsumeScreenVo.setData(Collections.singletonList(hashMaps));
     //   JSONArray.toJSONString(storeAndConsumeScreenVo)
        System.out.println(hashMaps);

        /*String s = JSONObject.toJSONString(hashMaps);
       JSONObject.parseArray(s, storeAndConsumeScreenVo.getStorePercent().getClass());*/
        // return JSON.toJSONString(storeAndConsumeScreenVo);

        return storeAndConsumeScreenVo;
    }

}
